<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript" src="/${initParam.rootPath }/se/js/HuskyEZCreator.js" charset="UTF-8"></script>

 <b style="font-size: 20px;">글 작성</b><p/>
<form name="boardForm" action="/${initParam.rootPath }/reviewsboard/writePost.do" method="post" 
enctype="multipart/form-data" onsubmit="return writeCheck(this);">
	<table align="center" style="width: 830px;">
		<tr>
			<td width="100px">제목</td>
			<td><input type="text" name="title" size="70"></td>
		</tr>
		<tr>
			<td>작성자</td>
			<td><input type="text" name="writer" value="${sessionScope.login_info.id }" readonly="readonly"></td>
		</tr>
		<tr>
			<td colspan="2">
				<textarea readonly="readonly" name="content" id="content" rows="20" cols="110"></textarea>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="submit" value="등록">
				<input type="reset" value="초기화">
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">
var oEditors = [];

nhn.husky.EZCreator.createInIFrame({
	oAppRef: oEditors,
	elPlaceHolder: "content",
	sSkinURI: "/${initParam.rootPath }/se/SmartEditor2Skin.html", 
	fOnAppLoad: function(){
    	//수정모드 구현시 사용할 부분
    	var title = localStorage.getItem("title");
    	var content = localStorage.getItem("content");
    	document.getElementById("title").value = title;
    	oEditors.getById["txtContent"].exec("PASTE_HTML", [content]);
    }, 
	fCreator: "createSEditor2"
});

	function writeCheck(form) {

		if (!form.title.value) {
			alert("제목을 입력하세요.");
			form.title.focus();
			return false;
		}

		oEditors.getById["content"].exec("UPDATE_CONTENTS_FIELD", []);

		var ch = document.getElementById("content").value;
		if (!ch || ch == '<p>&nbsp;</p>') {
			alert("내용을 입력하세요.");
			oEditors.getById["content"].exec("FOCUS", []);
			return false;
		} else {
			try {
				document.boardForm.submit();
			} catch (e) {}
		}
		

	};
	var pasteHTML = function(filename){
		var sHTML = '<img src="/${initParam.rootPath }/upload/'+filename+'">'; //사진 저장 경로
		oEditors.getById["content"].exec("PASTE_HTML", [sHTML]);
	};
</script>











